//
//  MKUIElementSelectOptionViewController.h
//  MKUI
//  选中某个、某些选项
//  Created by 苏尚进 on 2023/7/12.
//  Copyright © 2023 moon. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "MKUITableView.h"
#import "MKUIElementViewDetail.h"

NS_ASSUME_NONNULL_BEGIN
@interface MKUIElementSelectOption : NSObject
@property(nonatomic,strong,nullable) id value;
@property(nonatomic,strong,nullable) NSString *text;
@property(nonatomic,strong,nullable) NSDictionary *userInfo;
+ (MKUIElementSelectOption *)optionWithValue:(nullable id)value text:(nullable NSString *)text;
+ (MKUIElementSelectOption *)optionWithValue:(nullable id)value;
+ (NSArray<MKUIElementSelectOption *> *)optionsWithTexts:(NSArray<NSString *> *)texts;
+ (NSArray<MKUIElementSelectOption *> *)optionsWithTexts:(NSArray<NSString *> *)texts values:(NSArray *)values;
+ (NSArray<MKUIElementSelectOption *> *)optionsWithValues:(NSArray *)values textBlock:(NSString *(^)(id value))textBlock;
@end
NS_ASSUME_NONNULL_END

NS_ASSUME_NONNULL_BEGIN
@interface MKUIElementSelectOptionTableViewCell : MKUIElementTableViewCellDetail
@end
NS_ASSUME_NONNULL_END

NS_ASSUME_NONNULL_BEGIN

@interface MKUIElementSelectOptionViewController : UIViewController
@property(nonatomic,readonly) MKUITableView *tableView;
@property(nonatomic,strong,nullable) NSArray<MKUIElementSelectOption *> *options;//选项
@property(nonatomic,assign) BOOL allowsMultipleSelection;//是否允许多选

@property(nonatomic,strong,nullable) MKUIElementSelectOption *selectedOption;//选中的选项（单选）
@property(nonatomic,strong,nullable) id selectedValue;//选中的选项的值（单选）

@property(nonatomic,strong,nullable) NSArray<MKUIElementSelectOption *> *selectedOptions;//选中的选项（多选）
@property(nonatomic,strong,nullable) NSArray *selectedValues;//选中的选项（多选）

@property(nonatomic,strong,nullable) NSString *doneButtonText;//完成按钮的文字，默认为Done
@property(nonatomic,copy,nullable) void(^whenDone)(MKUIElementSelectOptionViewController *vc);//完成选择的回调
@property(nonatomic,copy,nullable) void(^whenChange)(MKUIElementSelectOptionViewController *vc);//选项变更时的回调

@property(nonatomic,assign) Class optionCellClass;//默认为MKUIElementSelectOptionTableViewCell
- (id)initWithStyle:(UITableViewStyle)style;
- (void)reloadData;
@end

NS_ASSUME_NONNULL_END
